<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@page import="com.yaodian100.core.common.utils.ServerValue"%>
<head>
<style type="text/css">
h1 span{visibility:visible;}
td span{visibility:visible;}
.msg{float:left; line-height:1em; margin:0; display:block;border:1px solid #f66;padding:2px 5px;*padding:2px 5px 1px;}
.msg.rn{background-color:#fff2f2;border-color:#f66;}
</style>
</head>
<c-rt:set var="midContextPath" value='<%=ServerValue.getMidContextPath() %>'/>
<c-rt:set var="frontHostname" value='<%=ServerValue.getFrontHostname() %>'/>
<!-- 月历 -->
<script type="text/javascript" charset="UTF-8" src="/js/jquery.datepick.js"></script>
<script type="text/javascript" charset="UTF-8" src="/js/jquery.datepick-zh-CN.js"></script>
<script type="text/javascript" charset="UTF-8" src="/js/yaodian100.common.js"></script>
<link rel="stylesheet" type="text/css" href="/css/smoothness.datepick.css" />
<script language="javascript">
	$().ready( function() {
		
		$('#startDate').datepick({minDate: new Date(), showOn:'both',numberOfMonths:2, buttonImageOnly: true, buttonImage: '/images/calendar.gif',dateFormat:"yy-mm-dd"}); 
		$('#endDate').datepick({minDate: new Date(),showOn: 'both',numberOfMonths:2, buttonImageOnly: true, buttonImage: '/images/calendar.gif',dateFormat:"yy-mm-dd"});
		$("#subBtn").click(function(){
			if ( validate_data() ){
				$("#advStatus").val("10");
				$("#idxGoldFourAdvForm").submit();
			}
		});

		$("#draftBtn").click(function(){
			if ( validate_data() ){
				$("#advStatus").val("00");
				$("#idxGoldFourAdvForm").submit();
			}
		});
		
		$("#canBtn").click(function(){
			if ( validate_data() ){
				$("#advStatus").val("90");
				$("#idxGoldFourAdvForm").submit();
			}
		});
	});
	
	function validate_data(){
		var isCorrect = true;
		$("span:[id*=Tip]").hide();
		$("span:[id*=Tip]").text('');
		if ( $("#advName").val() == "" ){
			$("#advNameTip").text("请输入广告名称");
			$("#advNameTip").show();
			isCorrect = false;
		}
		if ( $("#startDate").val() == ""){
			$("#startDateTip").text("请输入起始时间");
			$("#startDateTip").show();
			isCorrect = false;
		}

		if( $("#endDate").val() == "" ){
			$("#endDateTip").text("请输入结束时间");
			$("#endDateTip").show();
			isCorrect = false;
		}
		for( var i = 1; i <= 3; i++ ){
			for( var j = 1; j <=4; j++ ){
				if ( $("#advId").val() == "" ){
					if ( $("#tab" + i + "Img" + j).val() == ""){
						appendWord($("#tab" + i + "Tip"),"请选择图片"+j);
						$("#tab" + i + "Tip").show();
						isCorrect = false;
					}else{
						$("#tab" + i + "Img" + j + "Name").val($("#tab" + i + "Img" + j).val());
					}
				}
				if ( $("#tab" + i + "Img" + j +"Link").val() == ""){
					$("#tab" + i + "Img" + j +"LinkTip").text("图片"+j+"点击连结不能空白");
					$("#tab" + i + "Img" + j +"LinkTip").show();
					isCorrect = false;
				}else if ( !isURL($("#tab" + i + "Img" + j +"Link").val()) ){
					$("#tab" + i + "Img" + j +"LinkTip").text("图片"+j+"连结格式错误");
					$("#tab" + i + "Img" + j +"LinkTip").show();
					isCorrect = false;
				}
			}		
		}
		return isCorrect;
	}

	function appendWord(origin, apptext){
		if(origin.text().length==0){
			origin.text(apptext);
		}else{
			origin.text(origin.text()+', '+apptext);
		}
		
	}
</script>
<s:actionerror />
<s:actionmessage />
<s:fielderror />
<h1>广告管理</h1>
<s:form action="idxGoldFour/saveIdxGoldFourAdv.do" method="post" name="idxGoldFourAdvForm" id="idxGoldFourAdvForm" enctype="multipart/form-data">
	<table class="tb-data" width="100%">
		<tbody>
			<tr>
				<th>类型</th>
				<td>首页黄金四格商品<input type="hidden" name="advType" id="advType" value="${advType}"/></td>
			</tr>
			<tr>
				<th>广告名称</th>
				<td><input type="text" id="advName" name="advName" value="${advName}" size="30" maxlength="30"/><br/><span id="advNameTip" class="msg rn" style="display:none;"></span></td>
			</tr>
			<tr>
				<th>起迄时间</th>
				<td>
				<input type="text" id="startDate" name="startDate" value="${startDate}" maxlength="10"/> ~ 
				<input type="text" id="endDate" name="endDate" value="${endDate}" maxlength="10"/><br/>
				<span id="startDateTip" class="msg rn" style="display:none;"></span>   <span id="endDateTip" class="msg rn" style="display:none;"></span>
				</td>
			</tr>
			<tr>
				<th colspan="4">tab设定</th>
			</tr>
			<tr>
				<th>热销商品</th>
				<td>
					<c-rt:if test="${not empty advId}">
						<img src="${frontHostname }/eventImg/${tab1Img1Folder}/${advType}/${tab1Img1Name}" width="105" height="75"/><br/>
					</c-rt:if>
					<b>图片一:</b><s:file id="tab1Img1" name="tab1Img1" value="" size="55" ></s:file><br/><span class="txt-rd">图片尺寸:105x75</span><br/>
					<b>图片一点击连结:</b><input type="text" name="tab1Img1Link" id="tab1Img1Link" value="${tab1Img1Link}" size="60"/><br/>
					<span class="txt-rd">ex:http://www.yaodian100.com</span><br/>
					<input type="hidden" id="tab1Img1Name" name="tab1Img1Name" value="${tab1Img1Name}"/>
					<input type="hidden" name="tab1Img1Folder" value="${tab1Img1Folder}"/>
					
					<c-rt:if test="${not empty advId}">
						<img src="${frontHostname }/eventImg/${tab1Img2Folder}/${advType}/${tab1Img2Name}" width="105" height="75"/><br/>
					</c-rt:if>
					<b>图片二:</b><s:file id="tab1Img2" name="tab1Img2" value="" size="55" ></s:file><br/><span class="txt-rd">图片尺寸:105x75</span><br/>
					<b>图片二点击连结:</b><input type="text" name="tab1Img2Link" id="tab1Img2Link" value="${tab1Img2Link}" size="60"/><br/>
					<span class="txt-rd">ex:http://www.yaodian100.com</span><br/>
					<input type="hidden" id="tab1Img2Name" name="tab1Img2Name" value="${tab1Img2Name}"/>
					<input type="hidden" name="tab1Img2Folder" value="${tab1Img2Folder}"/>
					
					<c-rt:if test="${not empty advId}">
						<img src="${frontHostname }/eventImg/${tab1Img3Folder}/${advType}/${tab1Img3Name}" width="105" height="75"/><br/>
					</c-rt:if>
					<b>图片三:</b><s:file id="tab1Img3" name="tab1Img3" value="" size="55" ></s:file><br/><span class="txt-rd">图片尺寸:105x75</span><br/>
					<b>图片三点击连结:</b><input type="text" name="tab1Img3Link" id="tab1Img3Link" value="${tab1Img3Link}" size="60"/><br/>
					<span class="txt-rd">ex:http://www.yaodian100.com</span><br/>
					<input type="hidden" id="tab1Img3Name" name="tab1Img3Name" value="${tab1Img3Name}"/>
					<input type="hidden" name="tab1Img3Folder" value="${tab1Img3Folder}"/>
					
					<c-rt:if test="${not empty advId}">
						<img src="${frontHostname }/eventImg/${tab1Img4Folder}/${advType}/${tab1Img4Name}" width="105" height="75"/><br/>
					</c-rt:if>
					<b>图片四:</b><s:file id="tab1Img4" name="tab1Img4" value="" size="55" ></s:file><br/><span class="txt-rd">图片尺寸:105x75</span><br/>
					<b>图片四点击连结:</b><input type="text" name="tab1Img4Link" id="tab1Img4Link" value="${tab1Img4Link}" size="60"/><br/>
					<span class="txt-rd">ex:http://www.yaodian100.com</span><br/>
					<input type="hidden" id="tab1Img4Name" name="tab1Img4Name" value="${tab1Img4Name}"/>
					<input type="hidden" name="tab1Img4Folder" value="${tab1Img4Folder}"/>
					
					<span id="tab1Tip" class="msg rn" style="display:none;"></span>
					<span id="tab1Img1LinkTip" class="msg rn" style="display:none;"></span>
					<span id="tab1Img2LinkTip" class="msg rn" style="display:none;"></span>
					<span id="tab1Img3LinkTip" class="msg rn" style="display:none;"></span>
					<span id="tab1Img4LinkTip" class="msg rn" style="display:none;"></span>
				</td>
			</tr>
			<tr>
				<th>店长推荐</th>
				<td>
					<c-rt:if test="${not empty advId}">
						<img src="${frontHostname }/eventImg/${tab2Img1Folder}/${advType}/${tab2Img1Name}" width="105" height="75"/><br/>
					</c-rt:if>
					<b>图片一:</b><s:file id="tab2Img1" name="tab2Img1" value="" size="55" ></s:file><br/><span class="txt-rd">图片尺寸:105x75</span><br/>
					<b>图片一点击连结:</b><input type="text" name="tab2Img1Link" id="tab2Img1Link" value="${tab2Img1Link}" size="60"/><br/>
					<span class="txt-rd">ex:http://www.yaodian100.com</span><br/>
					<input type="hidden" id="tab2Img1Name" name="tab2Img1Name" value="${tab2Img1Name}"/>
					<input type="hidden" name="tab2Img1Folder" value="${tab2Img1Folder}"/>
					
					<c-rt:if test="${not empty advId}">
						<img src="${frontHostname }/eventImg/${tab2Img2Folder}/${advType}/${tab2Img2Name}" width="105" height="75"/><br/>
					</c-rt:if>
					<b>图片二:</b><s:file id="tab2Img2" name="tab2Img2" value="" size="55" ></s:file><br/><span class="txt-rd">图片尺寸:105x75</span><br/>
					<b>图片二点击连结:</b><input type="text" name="tab2Img2Link" id="tab2Img2Link" value="${tab2Img2Link}" size="60"/><br/>
					<span class="txt-rd">ex:http://www.yaodian100.com</span><br/>
					<input type="hidden" id="tab2Img2Name" name="tab2Img2Name" value="${tab2Img2Name}"/>
					<input type="hidden" name="tab2Img2Folder" value="${tab2Img2Folder}"/>
					
					<c-rt:if test="${not empty advId}">
						<img src="${frontHostname }/eventImg/${tab2Img3Folder}/${advType}/${tab2Img3Name}" width="105" height="75"/><br/>
					</c-rt:if>
					<b>图片三:</b><s:file id="tab2Img3" name="tab2Img3" value="" size="55" ></s:file><br/><span class="txt-rd">图片尺寸:105x75</span><br/>
					<b>图片三点击连结:</b><input type="text" name="tab2Img3Link" id="tab2Img3Link" value="${tab2Img3Link}" size="60"/><br/>
					<span class="txt-rd">ex:http://www.yaodian100.com</span><br/>
					<input type="hidden" id="tab2Img3Name" name="tab2Img3Name" value="${tab2Img3Name}"/>
					<input type="hidden" name="tab2Img3Folder" value="${tab2Img3Folder}"/>
					
					<c-rt:if test="${not empty advId}">
						<img src="${frontHostname }/eventImg/${tab2Img4Folder}/${advType}/${tab2Img4Name}" width="105" height="75"/><br/>
					</c-rt:if>
					<b>图片四:</b><s:file id="tab2Img4" name="tab2Img4" value="" size="55" ></s:file><br/><span class="txt-rd">图片尺寸:105x75</span><br/>
					<b>图片四点击连结:</b><input type="text" name="tab2Img4Link" id="tab2Img4Link" value="${tab2Img4Link}" size="60"/><br/>
					<span class="txt-rd">ex:http://www.yaodian100.com</span><br/>
					<input type="hidden" id="tab2Img4Name" name="tab2Img4Name" value="${tab2Img4Name}"/>
					<input type="hidden" name="tab2Img4Folder" value="${tab2Img4Folder}"/>
					
					<span id="tab2Tip" class="msg rn" style="display:none;"></span>
					<span id="tab2Img1LinkTip" class="msg rn" style="display:none;"></span>
					<span id="tab2Img2LinkTip" class="msg rn" style="display:none;"></span>
					<span id="tab2Img3LinkTip" class="msg rn" style="display:none;"></span>
					<span id="tab2Img4LinkTip" class="msg rn" style="display:none;"></span>
				</td>
			</tr>
			<tr>
				<th>街头热卖</th>
				<td>
					<c-rt:if test="${not empty advId}">
						<img src="${frontHostname }/eventImg/${tab3Img1Folder}/${advType}/${tab3Img1Name}" width="105" height="75"/><br/>
					</c-rt:if>
					<b>图片一:</b><s:file id="tab3Img1" name="tab3Img1" value="" size="55" ></s:file><br/><span class="txt-rd">图片尺寸:105x75</span><br/>
					<b>图片一点击连结:</b><input type="text" name="tab3Img1Link" id="tab3Img1Link" value="${tab3Img1Link}" size="60"/><br/>
					<span class="txt-rd">ex:http://www.yaodian100.com</span><br/>
					<input type="hidden" id="tab3Img1Name" name="tab3Img1Name" value="${tab3Img1Name}"/>
					<input type="hidden" name="tab3Img1Folder" value="${tab3Img1Folder}"/>
					
					<c-rt:if test="${not empty advId}">
						<img src="${frontHostname }/eventImg/${tab3Img2Folder}/${advType}/${tab3Img2Name}" width="105" height="75"/><br/>
					</c-rt:if>
					<b>图片二:</b><s:file id="tab3Img2" name="tab3Img2" value="" size="55" ></s:file><br/><span class="txt-rd">图片尺寸:105x75</span><br/>
					<b>图片二点击连结:</b><input type="text" name="tab3Img2Link" id="tab3Img2Link" value="${tab3Img2Link}" size="60"/><br/>
					<span class="txt-rd">ex:http://www.yaodian100.com</span><br/>
					<input type="hidden" id="tab3Img2Name" name="tab3Img2Name" value="${tab3Img2Name}"/>
					<input type="hidden" name="tab3Img2Folder" value="${tab3Img2Folder}"/>
					
					<c-rt:if test="${not empty advId}">
						<img src="${frontHostname }/eventImg/${tab3Img3Folder}/${advType}/${tab3Img3Name}" width="105" height="75"/><br/>
					</c-rt:if>
					<b>图片三:</b><s:file id="tab3Img3" name="tab3Img3" value="" size="55" ></s:file><br/><span class="txt-rd">图片尺寸:105x75</span><br/>
					<b>图片三点击连结:</b><input type="text" name="tab3Img3Link" id="tab3Img3Link" value="${tab3Img3Link}" size="60"/><br/>
					<span class="txt-rd">ex:http://www.yaodian100.com</span><br/>
					<input type="hidden" id="tab3Img3Name" name="tab3Img3Name" value="${tab3Img3Name}"/>
					<input type="hidden" name="tab3Img3Folder" value="${tab3Img3Folder}"/>
					
					<c-rt:if test="${not empty advId}">
						<img src="${frontHostname }/eventImg/${tab3Img4Folder}/${advType}/${tab3Img4Name}" width="105" height="75"/><br/>
					</c-rt:if>
					<b>图片四:</b><s:file id="tab3Img4" name="tab3Img4" value="" size="55" ></s:file><br/><span class="txt-rd">图片尺寸:105x75</span><br/>
					<b>图片四点击连结:</b><input type="text" name="tab3Img4Link" id="tab3Img4Link" value="${tab3Img4Link}" size="60"/><br/>
					<span class="txt-rd">ex:http://www.yaodian100.com</span><br/>
					<input type="hidden" id="tab3Img4Name" name="tab3Img4Name" value="${tab3Img4Name}"/>
					<input type="hidden" name="tab3Img4Folder" value="${tab3Img4Folder}"/>
					
					<span id="tab3Tip" class="msg rn" style="display:none;"></span>
					<span id="tab3Img1LinkTip" class="msg rn" style="display:none;"></span>
					<span id="tab3Img2LinkTip" class="msg rn" style="display:none;"></span>
					<span id="tab3Img3LinkTip" class="msg rn" style="display:none;"></span>
					<span id="tab3Img4LinkTip" class="msg rn" style="display:none;"></span>
				</td>
			</tr>						
			<tr>
				<td colspan="2">
					<input type="hidden" id="advId" name="advId" value="${advId}"/>
					<input type="hidden" id="advStatus" name="advStatus" value="${advStatus}"/>
					<input type="button" id="subBtn" name="subBtn" value="发送"/>
					<input type="button" id="draftBtn" name="draftBtn" value="草稿"/>
					<input type="button" id="canBtn" name="canBtn" value="暂停"/>
				</td>
			</tr>												
		</tbody>
	</table>
</s:form>
<div class="f-link">
	<a href="${midContextPath}/generate/searchIdx.do">回广告查询页</a>
</div>